package cn.zyx.org.service.impl;

import cn.zyx.basic.util.PageList;
import cn.zyx.org.domain.SystemDictionaryDetail;
import cn.zyx.org.mapper.SystemDictionaryDetailMapper;
import cn.zyx.org.query.SystemDictionaryDetailQuery;
import cn.zyx.org.service.ISystemDictionaryDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class SystemDictionaryDetailServiceImpl implements ISystemDictionaryDetailService {

    @Autowired
    private SystemDictionaryDetailMapper systemDictionaryDetailMapper;

    @Override
    @Transactional
    public void add(SystemDictionaryDetail systemDictionaryDetail) {
        systemDictionaryDetailMapper.save(systemDictionaryDetail);
    }

    @Override
    @Transactional
    public void remove(Long id) {
        systemDictionaryDetailMapper.delete(id);
    }

    @Override
    public List<SystemDictionaryDetail> getAll() {
        return systemDictionaryDetailMapper.loadAll();
    }

    @Override
    public SystemDictionaryDetail getById(Long id) {
        return systemDictionaryDetailMapper.loadById(id);
    }

    @Override
    @Transactional
    public void update(SystemDictionaryDetail systemDictionaryDetail) {
        systemDictionaryDetailMapper.update(systemDictionaryDetail);
    }

    @Override
    public PageList<SystemDictionaryDetail> getDetailById(SystemDictionaryDetailQuery systemDictionaryDetailQuery) {
        // 查询总条数
        Integer total = systemDictionaryDetailMapper.detailPageCount(systemDictionaryDetailQuery);
        // 查询当前页数据
        List<SystemDictionaryDetail> rows = systemDictionaryDetailMapper.detailPageData(systemDictionaryDetailQuery);
        return new PageList<>(total,rows);
    }

}
